<?php
/**
 * Created by PhpStorm.
 * User: CYJiao
 * Date: 6/6/15
 * Time: 16:45
 */
?>


<script>
    $(function(){
        $(window).resize(function(){
            $('#datagrid1').datagrid('resize', {
                width:function(){
                    return document.body.clientWidth;
                },
                height:function(){
                    return document.body.clientHeight;
                }
            });
        });

        $('#datagrid1').datagrid({
            url: '<?php echo Yii::app()->request->baseUrl; ?>/data/datagrid_data1.json',
            pagination: true,
            fit: true,
            height: 'auto',
            striped: true,
            remoteSort:false,
            fitColumns: false,
            nowrap: false,
            border: false,
            singleSelect:false,
            rownumbers:true,//行号
            frozenColumns:[[
                {field:'ck',checkbox:true},
                {field:'productid',title:'药品ID',sortable:true}
            ]],
            idField: 'id', // 跨页选择使用
            columns:
                [[
                    {
                        title:'药品价格',
                        field:'unitcost',
                        width:100
                    },{
                        title:'药品号',
                        field:'phone',
                        width:100
                    },{
                        title:'药品价目',
                        field:'listprice',
                        width:100
                    },{
                        title:'药品属性',
                        field:'attr1',
                        width:100
                    },{
                        title:'药品货单',
                        field:'itemid',
                        width:100
                    }
                ]],
            toolbar: '#toolbar1'
        });

        //设置分页控件
        var p = $('#datagrid1').datagrid('getPager');
        $(p).pagination({
            pageSize: 10,
            pageList: [10,20,30,40,50,60,70,80,90,100],
            onBeforeRefresh:function(){
                $(this).pagination('loading');
                alert('before refresh');
                $(this).pagination('loaded');
            }
        });
    });

</script>

<div class="easyui-layout" data-options="border:false,fit:true">
    <div data-options="region:'center',fit:true,border:false" style="overflow: hidden;">
        <table id="datagrid1" data-options="border:false,fit:true" style="height: 500px;">
        </table>
        <div id="toolbar1">
            <table style="border-spacing:0">
                <tr>
                    <td>
                        <input class="easyui-searchbox" style="width:150px" />
                    </td>
                    <td>
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="">添加</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
